<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>清除本地数据</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background-color: #f0f0f0;
        }
        .container {
            text-align: center;
            padding: 20px;
            background-color: white;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }
        button {
            padding: 10px 20px;
            font-size: 16px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }
        button:hover {
            background-color: #45a049;
        }
        #result {
            margin-top: 20px;
            padding: 10px;
            border-radius: 4px;
        }
        .success {
            background-color: #d4edda;
            color: #155724;
        }
        .error {
            background-color: #f8d7da;
            color: #721c24;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>清除本地数据</h1>
        <p>点击下方按钮清除所有本地存储的模拟数据</p>
        <button onclick="clearAllData()">清除数据</button>
        <div id="result"></div>
    </div>

    <script>
        function clearAllData() {
            try {
                // 清除所有模拟数据
                localStorage.removeItem('mock_students');
                localStorage.removeItem('mock_classes');
                localStorage.removeItem('mock_dormitories');
                localStorage.removeItem('mock_teachers');
                localStorage.removeItem('mock_captchas');
                localStorage.removeItem('mock_smsCodes');
                
                // 显示成功消息
                const result = document.getElementById('result');
                result.textContent = '所有本地数据已成功清除！请刷新应用页面。';
                result.className = 'success';
                
                console.log('Local storage data cleared successfully');
            } catch (error) {
                // 显示错误消息
                const result = document.getElementById('result');
                result.textContent = '清除数据时出错：' + error.message;
                result.className = 'error';
                
                console.error('Error clearing local storage:', error);
            }
        }
    </script>
</body>
</html>